//
//  FXTHttpRequestModel.m
//  OfferJob
//
//  Created by 郑州动力无限科技 on 2017/6/30.
//  Copyright © 2017年 郑州动力无限科技. All rights reserved.
//

#import "FXTHttpRequestModel.h"
//#import "FXTHttpResponseModel.h"
@implementation FXTHttpRequestModel
@synthesize flag = _flag;
@synthesize callback = _callback;

-(instancetype)init {
    if (self =[super init]) {
        self.type =FXTHttpType_POST;
        self.localHost =kTestHttpHost;
    }
    return self;
}
- (NSDictionary *)reqParamDic {
    return nil;
}

- (void)requestFinishedCallback:(id)result {
    
    //    NSNumber *isSuccess =result[@"type"];
    if ([result isKindOfClass:[NSDictionary class]]) {
        FXTHttpResponseModel *reponse = [self getResponseWithInfo:result err:nil];// 对callBack进行数据包装，方便判断
        if (self.callback) {
            self.callback(reponse,nil);
        }
    }else {
        NSError *error =[NSError errorWithDomain:@"未知数据类型" code:-1 userInfo:nil];
        if (self.callback) {
            self.callback(nil,error);
        }
    }
    
    
}
- (void)requestErrorCallback:(NSError *)error {
    
    self.callback(nil,error);
    
}
- (id<FXTResponseDelegate>)getResponseWithInfo:(id)result
                                          err:(NSError *)err    {
    FXTHttpResponseModel *reponse =[[FXTHttpResponseModel alloc]initWithData:result err:err];
    return reponse;
}
-(NSMutableDictionary *)paramDic {
    if (!_paramDic) {
        _paramDic =[NSMutableDictionary dictionary];
    }
    return _paramDic;
}
@end
